package com.oceansoft.mobile.econsole.modules.dcn.plugin;

import com.google.common.base.Strings;
import com.oceansoft.mobile.econsole.modules.dcn.entity.Command;
import com.oceansoft.mobile.econsole.modules.dcn.entity.RespCmd;
import com.oceansoft.mobile.econsole.modules.jlapi.entity.InQueryServiceInfo;
import com.oceansoft.mobile.econsole.modules.jlapi.entity.OutQueryServiceInfo2;
import com.oceansoft.mobile.econsole.modules.jlapi.persistence.IJlApiInfoMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

/**
 * ClassName: ACExpireWarnPlugin
 * Desc:  违章提醒
 * Date： 2016/11/16
 * Created：shaom
 */
@Component
public class VVExpireWarnPlugin extends AbstractExpireNoticePlugin {

    private static final Logger logger = LoggerFactory.getLogger(VVExpireWarnPlugin.class);

    @Resource
    private IJlApiInfoMapper jlApiInfoMapper;

    @Override
    public String command() {
        return InQueryServiceInfo.API_014;
    }

    @Override
    public void dealData(Command command) {
        RespCmd respCmd = (RespCmd) command;
        List<OutQueryServiceInfo2> outQueryServiceInfos = jlApiInfoMapper.queryListOutServiceInfo2(respCmd.getSerialNum());
        for (OutQueryServiceInfo2 queryServiceInfo : outQueryServiceInfos) {
            // 3-2 推送
            String res = queryServiceInfo.getRes();
            if (Strings.isNullOrEmpty(res)) {
                logger.info("返回的OUT-ATT表数据为空！");
                continue;
            }
            respCmd.setResult(res);
            super.sendMsg(command);
        }
    }
}
